Sliding Bar


In [1]:
import math
import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
n_points = 1000
L = 1.0
x = []
y = []
for i in range(n_points):
    pos_x = i * L/(n_points-1)
    pos_y = math.sqrt(L**2 - pos_x**2) 
    x.append(pos_x/2.0)
    y.append(pos_y/2.0)
plt.figure()
plt.axes().set_aspect('equal')
plt.plot(x,y)
plt.xlim(0.0,0.55)
plt.ylim(0.0,0.55)
plt.xlabel("x (meters)")
plt.ylabel("y (meters)")


Out[2]:
Text(0,0.5,'y (meters)')